var t = getApp();

Page({
    data: {
        language: "",
        inpvalue: "",
        left_show: !1,
        right_show: !1,
        testarr: [ "一级标题", "二级标题", "三级标题", "四级标题" ],
        openSelect: !1,
        show_num: "",
        name: 1,
        result: [],
        first_name: "",
        ind: "",
        twos: "",
        page: 1,
        json: {}
    },
    onLoad: function(t) {
        this.setData({
            store_id: t.store_id
        }), this.getStoreInfo(), this.getdata();
    },
    ischang: function(t) {
        console.log(t);
    },
    bindPickerChange: function(t) {
        var a = t.detail.value;
        this.setData({
            first_name: this.data.category[a].name,
            parentid: this.data.category[a].id,
            twos_list: this.data.category[a].childrens
        });
        var o = {
            store_id: this.data.store_id,
            page: "1",
            category: {
                parentid: this.data.parentid,
                childid: ""
            }
        };
        this.setData({
            isjson: o
        }), this.flSearch(this.data.isjson);
    },
    bindPickerChange_two: function(t) {
        var a = t.detail.value;
        console.log(a), this.setData({
            twos_name: this.data.twos_list[a].name,
            childid: this.data.twos_list[a].id
        });
        var o = {
            store_id: this.data.store_id,
            page: "1",
            category: {
                parentid: this.data.parentid,
                childid: this.data.childid
            }
        };
        this.setData({
            isjson: o
        }), this.flSearch(this.data.isjson);
    },
    inpbtn: function(t) {
        console.log(t.detail.value), this.setData({
            inpvalue: t.detail.value
        });
    },
    inpbtnclear: function(t) {
        console.log(t.detail.value);
    },
    tapOn: function(t) {
        console.log(t.currentTarget.dataset.tap);
        var a = t.currentTarget.dataset.tap;
        "left" == a ? this.setData({
            left_show: !this.data.left_show
        }) : "right" == a && this.setData({
            right_show: !this.data.right_show
        });
    },
    checkAll: function(t) {
        console.log(t);
    },
    rentAllSelectHandle: function(t) {
        console.log(t), this.setData({
            result: t.detail
        });
    },
    tapfirst: function(t) {
        console.log(t.currentTarget.dataset.name), this.setData({
            first_name: t.currentTarget.dataset.name
        });
    },
    btntap: function() {
        console.log(this.data.result);
        var t = {
            store_id: this.data.store_id,
            choose_goods: this.data.result
        };
        this.tapPush(t);
    },
    goText: function() {
        wx.navigateTo({
            url: "/packageD/o2o/recommendtext/recommendtext?store_id=" + this.data.store_id + "&&show_num=" + this.data.show_num
        });
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (console.log(this.data.current_page, this.data.last_page), console.log(this.data.json), 
        console.log(t._isTextEmpty(this.data.json)), this.data.current_page <= this.data.last_page) wx.showToast({
            title: "没有更多",
            icon: "none",
            duration: 1500
        }); else if (this.data.current_page > this.data.last_page) {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), t._isTextEmpty(this.data.json) ? this.getStoreInfo() : this.loadinginfo(this.data.json);
        }
    },
    onShareAppMessage: function() {},
    getdata: function() {
        var a = this, o = t.getNetAddresss("plugin.store-cashier.frontend.store.near-by-goods.get-store-goods");
        t._postNetWork({
            url: o,
            data: {
                store_id: a.data.store_id
            },
            success: function(t) {
                var o = t.data;
                console.log(o), 1 == o.result ? a.setData({
                    show_num: o.data.show_num
                }) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getStoreInfo: function() {
        var a = this, o = t.getNetAddresss("plugin.store-cashier.frontend.store.near-by-goods.index");
        t._postNetWork({
            url: o,
            data: {
                store_id: a.data.store_id,
                page: this.data.page
            },
            success: function(t) {
                var o = t.data;
                console.log(o), 1 == o.result ? (a.setData({
                    goods_data: o.data.goods_data.data,
                    category: o.data.category,
                    current_page: o.data.goods_data.current_page,
                    last_page: o.data.goods_data.last_page
                }), console.log(o.data.goods_data)) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    flSearch: function(a) {
        var o = this, e = t.getNetAddresss("plugin.store-cashier.frontend.store.near-by-goods.get-goods-list");
        t._postNetWork({
            url: e,
            data: a,
            success: function(t) {
                var a = t.data;
                console.log(a), 1 == a.result ? (o.setData({
                    goods_data: a.data.list.data,
                    current_page: a.data.list.current_page,
                    last_page: a.data.list.last_page
                }), 0 == a.data.list.data.length && wx.showToast({
                    icon: "none",
                    title: "没有相关商品",
                    duration: 1500
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    loadinginfo: function(a) {
        var o = this, e = t.getNetAddresss("plugin.store-cashier.frontend.store.near-by-goods.get-goods-list");
        t._postNetWork({
            url: e,
            data: a,
            success: function(t) {
                var a = t.data;
                console.log(a), 1 == a.result ? (o.setData({
                    goods_data: a.data.list.data,
                    current_page: a.data.current_page,
                    last_page: a.data.last_page
                }), 0 == a.data.list.data.length && wx.showToast({
                    icon: "none",
                    title: "没有相关商品",
                    duration: 1500
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    tapPush: function(a) {
        var o = t.getNetAddresss("plugin.nearby-store-goods.frontend.controllers.goods.index");
        t._postNetWork({
            url: o,
            data: a,
            success: function(t) {
                var a = t.data;
                console.log(a), 1 == a.result ? wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500,
                    success: function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});